﻿#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>

typedef double Real;

 

typedef struct
{
	int A; 
}Context;
Context context = { 0 };

void read_data(Context* ctx)
{
	scanf("%d", &ctx->A);
}  

void solve(Context* ctx)
{
	int A = ctx->A;
	int m = 0;
	for (int i = 0; i < 4; ++i) {
		for (int j = 0; j < 4; ++j) {
			for (int k = 0; k < 4; ++k) {
				if (i != j && i != k && j != k) {
					if (m > 0)
						printf(" ");
					printf("%d%d%d", A + i, A + j, A + k);
					if (++m == 6) {
						printf("\n");
						m = 0;
					}
				}
			}
		}
	}
}

int main()
{
	freopen("D:/Develop/GitRepos/MOOC/浙江大学/数据结构/201906/DataStructure/M2019秋C入门和进阶练习集/7-175.txt", "r", stdin);
	read_data(&context);
	solve(&context);
	return 0;
}
